<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  
 </head>
 <body>
  <t:formvalid formid="formobj" dialog="true" layout="table"
  	 action="ScoreManageController.do?doSetScore" tiptype="3" beforeSubmit="validateForm">
					 
		<input type="hidden" name="semester" value="${semester.id}" />
		<input type="hidden" name="scoreItem1Weight" id="scoreItem1Weight" value="${score.scoreItem1Weight }" />
		<input type="hidden" name="scoreItem2Weight" id="scoreItem2Weight" value="${score.scoreItem2Weight }" />
		<input type="hidden" name="scoreItem3Weight" id="scoreItem3Weight" value="${score.scoreItem3Weight }" />
		<input type="hidden" name="scoreItem4Weight" id="scoreItem4Weight" value="${score.scoreItem4Weight }" />
		<input type="hidden" name="scoreItem5Weight" id="scoreItem5Weight" value="${score.scoreItem5Weight }" />
		
		<input type="hidden" name="item1Name" id="scoreItem1Name" value="${score.item1Name}" />
		<input type="hidden" name="item2Name" id="scoreItem2Name" value="${score.item2Name}" />
		<input type="hidden" name="item3Name" id="scoreItem3Name" value="${score.item3Name}" />
		<input type="hidden" name="item4Name" id="scoreItem4Name" value="${score.item4Name}" />
		<input type="hidden" name="item5Name" id="scoreItem5Name" value="${score.item5Name}" />
		
		
		<table style="" cellpadding="0" cellspacing="1" class="formtable">  
				 
				<tr>
					<td align="right">
						<label class="Validform_label">
							学期：
						</label>
					</td>
					<td class="value">
						 ${semester.semesterName }							 
					</td>
				</tr>
				
				<tr>
					<td align="right">
						<label class="Validform_label">
							学生：
						</label>
					</td>
					<td class="value">
						<input id="teacherId" name="studentId" type="hidden"  value='${score.student.id }'>               
					     <input id="realName"  datatype="*" type="text" style="width: 150px" class="inputxt" value="${score.student.realName}" readonly="readonly" >
					     <t:choose hiddenName="teacherId" hiddenid="id" url="studentController.do?goSelect" name="studentList"
                          icon="icon-search" title="选择" textname="realName" isclear="false" isInit="true"  ></t:choose>
                          <span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">学生</label>
					</td>
				</tr>
				
				<tr>
					<td align="right">
						<label class="Validform_label">
							课程：
						</label>
					</td>
					<td class="value">
						<input id="lessonId" name="lessonId" type="hidden" value="${lesson.id}" >               
						<input id="lessonName"  type="text" style="width: 150px" class="inputxt" 
					      readonly="readonly"   datatype="*" value="${lesson.lessonName}">
						<t:choose hiddenName="lessonId" hiddenid="id" url="lessonInfoController.do?goSelect" name="lessonList"
                          icon="icon-search" title="选择" textname="lessonName" isclear="false" isInit="true" fun="afterSelect" ></t:choose>
                         
                        <span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">课程</label>                          							 
					</td>
				</tr>
				 
				<tr id="item1TR">
					<td align="right">
						<label class="Validform_label">
							<span id="item1Name">项目1</span>成绩：
						</label>
					</td>
					<td class="value">
					     <input  id="item1Score" name="item1Score" type="text" style="width: 100px" class="inputxt" value="${score.item1Score }">
					</td>
				</tr> 
				<tr id="item2TR">
					<td align="right">
						<label class="Validform_label">
							<span id="item2Name">项目2</span>成绩：
						</label>
					</td>
					<td class="value">
					     <input  id="item2Score" name="item2Score" type="text" style="width: 100px" class="inputxt" value="${score.item2Score }">
					</td>
				</tr> 
				<tr id="item3TR">
					<td align="right">
						<label class="Validform_label">
							<span id="item3Name">项目3</span>成绩：
						</label>
					</td>
					<td class="value">
					     <input  id="item3Score" name="item3Score" type="text" style="width: 100px" class="inputxt" value="${score.item3Score }">
					</td>
				</tr> 
				<tr id="item4TR">
					<td align="right">
						<label class="Validform_label">
							<span id="item4Name">项目4</span>成绩：
						</label>
					</td>
					<td class="value">
					     <input  id="item4Score" name="item4Score" type="text" style="width: 100px" class="inputxt" value="${score.item4Score }">
					</td>
				</tr> 
				<tr id="item5TR">
					<td align="right">
						<label class="Validform_label">
							<span id="item5Name">项目5</span>成绩：
						</label>
					</td>
					<td class="value">
					     <input  id="item5Score" name="item5Score" type="text" style="width: 100px" class="inputxt" value="${score.item5Score }">
					</td>
				</tr> 
			 
			</table>
		</t:formvalid>
		
		<script>
		
			var item1Name,weight1,item2Name,weight2,item3Name,weight3,item4Name,weight4,item5Name,weight5 = "";
			
			$(document).ready(function(){
				afterSelect(null);
			});
		
			function afterSelect(iframeInfo){
				
				if(iframeInfo != null){
					hideAll();
					item1Name = iframeInfo.getlessonListSelections("scoreItem1Name");
					weight1 = iframeInfo.getlessonListSelections("scoreItem1Weight");
					item2Name = iframeInfo.getlessonListSelections("scoreItem2Name");
					weight2 = iframeInfo.getlessonListSelections("scoreItem2Weight");
					item3Name = iframeInfo.getlessonListSelections("scoreItem3Name");
					weight3 = iframeInfo.getlessonListSelections("scoreItem3Weight");
					item4Name = iframeInfo.getlessonListSelections("scoreItem4Name");
					weight4 = iframeInfo.getlessonListSelections("scoreItem4Weight");
					item5Name = iframeInfo.getlessonListSelections("scoreItem5Name");
					weight5 = iframeInfo.getlessonListSelections("scoreItem5Weight");
				}else{
					$('#item1TR').hide();$('#item2TR').hide();$('#item3TR').hide();$('#item4TR').hide();$('#item5TR').hide();
					item1Name = $("#scoreItem1Name").val();
					weight1   = $('#scoreItem1Weight').val();
					item2Name = $("#scoreItem2Name").val();
					weight2   = $('#scoreItem2Weight').val();
					item3Name = $("#scoreItem3Name").val();
					weight3   = $('#scoreItem3Weight').val();
					item4Name = $("#scoreItem4Name").val();
					weight4   = $('#scoreItem4Weight').val();
					item5Name = $("#scoreItem5Name").val();
					weight5   = $('#scoreItem5Weight').val();
				}
				
				if(iframeInfo != null){
					$('#scoreItem1Weight').val(weight1);$('#scoreItem2Weight').val(weight2);
					$('#scoreItem3Weight').val(weight3);$('#scoreItem4Weight').val(weight4);
					$('#scoreItem5Weight').val(weight5);
					
					$('#scoreItem1Name').val(item1Name);$('#scoreItem2Name').val(item2Name);
					$('#scoreItem3Name').val(item3Name);$('#scoreItem4Name').val(item4Name);
					$('#scoreItem5Name').val(item5Name);	
				}
				
				
				if(item1Name != ''){
					$('#item1TR').show();
					$('#item1Name').text(item1Name);
				}
				if(item2Name != ''){
					$('#item2TR').show();
					$('#item2Name').text(item2Name);
				}
				if(item3Name != ''){
					$('#item3TR').show();
					$('#item3Name').text(item3Name);
				}
				if(item4Name != ''){
					$('#item4TR').show();
					$('#item4Name').text(item4Name);
				}
				if(item5Name != ''){
					$('#item5TR').show();
					$('#item5Name').text(item5Name);
				}
			}
			
			function hideAll(){
				$('#item1TR').hide();$('#item2TR').hide();$('#item3TR').hide();$('#item4TR').hide();$('#item5TR').hide();
				
				$('#scoreItem1Weight').val('');$('#scoreItem2Weight').val('');$('#scoreItem3Weight').val('');
				$('#scoreItem4Weight').val('');$('#scoreItem5Weight').val('');
				
				$('#scoreItem1Name').val('');$('#scoreItem2Name').val('');$('#scoreItem3Name').val('');
				$('#scoreItem4Name').val('');$('#scoreItem5Name').val('');
			}
			
			function validateForm(){
				if(item1Name != ''){
					if($('#item1Score').val() == ''){
						tip("请输入"+item1Name+"的成绩");
						$('#item1Score').focus();
						return false;
					}
				}
				if(item2Name != ''){
					if($('#item2Score').val() == ''){
						tip("请输入"+item2Name+"的成绩");
						$('#item2Score').focus();
						return false;
					}
				}
				if(item3Name != ''){
					if($('#item3Score').val() == ''){
						tip("请输入"+item3Name+"的成绩");
						$('#item3Score').focus();
						return false;
					}
				}
				if(item4Name != ''){
					if($('#item4Score').val() == ''){
						tip("请输入"+item4Name+"的成绩");
						$('#item4Score').focus();
						return false;
					}
				}
				if(item5Name != ''){
					if($('#item5Score').val() == ''){
						tip("请输入"+item5Name+"的成绩");
						$('#item5Score').focus();
						return false;
					}
				}
				return true;
			}
		</script>
 </body>